package com.kingsoft.dc.khaos.extender.meta.impl;

import com.alibaba.fastjson.JSON;
import com.kingsoft.dc.khaos.extender.meta.model.ds.Connect;
import com.kingsoft.dc.khaos.extender.meta.model.ds.SqlServerConnect;
import com.kingsoft.dc.khaos.extender.meta.utils.RSAEncrypt;

/**
 * SqlServer数据管理元数据实现
 * Created by fanshengli on 19/6/25.
 */
public class SqlServerDmMetaImpl extends DmMetaImpl {

    /**
     * 构造SqlServerConnect并对密码加密
     * @param config
     * @return
     */
    @Override
    public Connect decryptDatasourceConnectSecret(String config) {
        SqlServerConnect connect = JSON.parseObject(config, SqlServerConnect.class);
        try {
            connect.setPassWord(RSAEncrypt.decryptByRSAPassWord(connect.getPassWord()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return connect;
    }

}
